package com.assistant.query.controller;

import com.assistant.common.Result;
import com.assistant.query.pojo.QueryVO;
import com.assistant.query.service.QueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname QueryController
 * @Description TODO
 * @Date 2025/3/4 10:14
 * @Created by xxx
 */
@RestController
@RequestMapping("/api/v1/query")
@Slf4j
public class QueryController {

    @Autowired
    private QueryService queryService;

    /**
     * 问答接口
     *
     * @param question
     * @return String
     */
    @PostMapping
    public Result query(@RequestBody QueryVO question) {
        log.info("query question: {}", question.getQuestion());
        String answer = queryService.query(question.getQuestion());
        return Result.success(answer);
    }
}
